package com.dreamfire.io.net
{
	import com.dreamfire.core.Client;
	import com.dreamfire.data.DataManager;
	import com.dreamfire.data.event.SceneEvent;

	public class ServerManager
	{
		private static var _instance:ServerManager;
		
		private var _socket:SocketConnector;
		
		public function ServerManager()
		{
			_socket = new SocketConnector();
		}
		
		public static function get instance():ServerManager
		{
			if(_instance == null)
				_instance = new ServerManager();
			return _instance;
		}
		
		public function connect():void
		{
			_socket.handleFunction = received;
			_socket.connect("127.0.0.1", 8000);
		}
		
		public function send(data:Object):void
		{
			_socket.send(data);
		}
		
		public function received(data:Object):void
		{
			DataManager.instance.secneUpdate(data);
		}
	}
}